﻿using M.ShopMachine.Repository.Interface;
using M.ShopMachine.Write.WebApi.Application.Command.WorkshopCommand;
using MediatR;

namespace M.ShopMachine.Write.WebApi.Application.Handler.WorkshopHandler
{
    public class UpdStateWorkshopHandler : IRequestHandler<UpdStateWorkshopCommand, int>
    {
        private readonly IWorkshopRepository workshopRepository;

        public UpdStateWorkshopHandler(IWorkshopRepository workshopRepository)
        {
            this.workshopRepository = workshopRepository;
        }

        public async Task<int> Handle(UpdStateWorkshopCommand request, CancellationToken cancellationToken)
        {
            return await workshopRepository.UpdStateAsync(request.id, request.State);
        }
    }
}
